<template>
  <div class="login">
    <div class="con">
      <h3 class="text-center h3">登录</h3>

      <el-input v-model="user.username" clearable placeholder="请输入用户名"></el-input>
      <el-input v-model="user.password" clearable show-password placeholder="请输入密码"></el-input>
      <div class="text-center">
        <el-button type="primary" @click="login">登录</el-button>
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import { requserlogin } from "../../http/api";

export default {
  props: [],
  data() {
    return {
      user: {
        username: "",
        password: ""
      }
    };
  },
  computed: {
    ...mapGetters({
    }),
  },
  mounted() {

  },
  methods: {
    ...mapActions({
      changeUserInfo:"changeUserInfo"
    }),
    login() {
      //登录逻辑
      requserlogin(this.user).then(res => {
        if (res.data.code == 200) {
          this.changeUserInfo(res.data.list)
          this.$router.push('/')
        }
      });
    }
  }
};
</script>
<style scoped lang='less'>
@import "../../less/index.less";

.login {
  width: 100vw;
  height: 100vh;
  background: linear-gradient(to right, @primary-light, @primary-deep);
  position: absolute;
}
.con {
  position: absolute;
  width: 300px;
  padding: @padding20;
  background: #fff;
  border-radius: @padding10;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  .el-input {
    margin-bottom: @margin20;
  }
  .h3 {
    margin: 10px;
  }
}
</style>